<?php
!defined('P_W') && exit('Forbidden');

class PW_House_BrokerRightDB extends BaseDB {
	var $_tableName = "pw_house_brokerright";
	var $_primaryKey = 'groupid';
	
	/**
	 * 获取经纪人组权限
	 * @param $groupid
	 */
	function getRightsByGroupid($groupid) {
		$_sql = 'SELECT * FROM '.$this->_tableName.' WHERE '.$this->_primaryKey.'='.pwEscape($groupid);
		$query = $this->_db->query($_sql);
		return $this->_getAllResultFromQuery($query);
	}
	/**
	 * 更新一条用户组权限
	 * @param $groupid		经纪人组id
	 * @param $rightKey		权限key
	 * @param $rightValue	权限值
	 */
	function update($groupid,$rightKey,$rightValue) {
		$_sql = 'REPLACE INTO '.$this->_tableName.' SET groupid='.pwEscape($groupid).', rightkey='.pwEscape($rightKey).', rightvalue = '.pwEscape($rightValue);
		return $this->_db->update('REPLACE INTO '.$this->_tableName.' SET groupid='.pwEscape($groupid).', rightkey='.pwEscape($rightKey).', rightvalue = '.pwEscape($rightValue));
	}
	
	function getStruct() {
		return array('groupid', 'rightkey','rightvalue');
	}
}